#{extends '/template/main.html' /}
<!-- Removing search and results count filter -->
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">商户管理</h3>
    </div>
    <div class="panel-body">
        <form method="get" id="searchForm" action="/BS0007/admin/merchant/index/${pageNumber}">
            <input type="hidden" value="${pageNumber}" id="pageNumber"  />
            <div style="margin-bottom: 20px;width:160px;float: left;">
                <input type="text" name="merchantName" id="merchantName" class="form-control" style="width:150px" placeholder="商户名称" value="${merchantName}">
            </div>
            <div style="margin-bottom: 20px;width:160px;float: left;">
                <input type="text" name="phone" id="phone" class="form-control" style="width:150px" placeholder="手机号" value="${phone}">
            </div>
            <div style="margin-bottom: 20px;width:160px;float: left;">
                <input type="text" name="loginName" id="loginName" class="form-control" style="width:150px" placeholder="登录名" value="${loginName}">
            </div>
            <div style="margin-bottom: 20px;width:160px;float: left;">
                <select name="verifyState" class="form-control" style="width: 120px">
                    <option value="" ${verifyState == null ? 'selected' : ''}>审核状态</option>
                    <option value="WAIT" ${verifyState.toString() == 'WAIT' ? 'selected' : ''}>新用户</option>
                    <option value="VERIFY" ${verifyState.toString() == 'VERIFY' ? 'selected' : ''}>待审核</option>
                    <option value="PASS" ${verifyState.toString() == 'PASS' ? 'selected' : ''}>已审核</option>
                    <option value="NOTPASS" ${verifyState.toString() == 'NOTPASS' ? 'selected' : ''}>审核不通过</option>
                    <option value="CLOSE" ${verifyState.toString() == 'CLOSE' ? 'selected' : ''}>店铺关闭</option>
                </select>
            </div>
        </form>
        <button class="btn btn-turquoise" id="searchBtn">开始检索</button>
        <button class="btn btn-turquoise" onclick="exportExcel()">导出</button>
        <table class="table table-bordered table-striped" id="example-2">
            <thead>
            <tr>
                <th class="no-sorting">
                    <input type="checkbox" class="cbr">
                </th>
                <th>店名</th>
                <th>登录名</th>
                <th>商户Logo</th>
                <th>电话</th>
                <th>被投诉次数</th>
                <th>投诉成功次数</th>
                <th>操作</th>
            </tr>
            </thead>

            <tbody class="middle-align">
            #{paginate.list items:resultPage , as :'merchant'}
            <tr>
                <td>
                    <input type="checkbox" class="cbr">
                </td>
                <td>  <a href="/BS0007/admin/merchant/goSee/${merchant?.id}/${pageNumber}" >
                ${merchant?.name}
                </a></td>
                <td>${merchant?.loginName}</td>
                <td>#{if merchant.imagePath != null &&  merchant.imagePath != "imgSrc" }<img src="${merchant?.imagePath}" style="width: 40px;">#{/if}</td>
                <td>${merchant?.servicePhone}</td>
                <td>${merchant?.beComplaintCount == null ? 0:merchant?.beComplaintCount}</td>
                <td>${merchant?.complaintCount == null ?0:merchant?.complaintCount}</td>
                <td>
                    <a href="/BS0007/admin/merchant/goSee/${merchant?.id}/${pageNumber}" class="btn btn-danger btn-sm btn-icon icon-left">
                        查看
                    </a>
                    #{if merchant.verifyState.toString() == 'VERIFY' }
                        <a href="/BS0007/admin/merchant/modify/${merchant?.id}/${pageNumber}" class="btn btn-secondary btn-sm btn-icon icon-left">
                            审核
                        </a>
                    #{/if}
                    <a href="/BS0007/admin/merchant/withdrawList?merId=${merchant?.id}" class="btn btn-danger btn-sm btn-icon icon-left">
                        提现明细
                    </a>
                    #{if merchant.verifyState.toString() == 'PASS' }
                        <a href="/BS0007/admin/merchant/closeMer/${merchant?.id}/${pageNumber}" class="btn btn-danger btn-sm btn-icon icon-left">
                            冻结
                        </a>
                        <a href="/BS0007/admin/merchant/goGrade/${merchant?.id}/${pageNumber}" class="btn btn-danger btn-sm btn-icon icon-left">
                            评分
                        </a>
                    #{/if}

                </td>
            </tr>
            #{/paginate.list}

            </tbody>
        </table>
        <div id="layerPage" class="col-xs-12"></div>
    </div>
</div>

<!-- Imported styles on this page -->
<link rel="stylesheet" href="/public/js/datatables/dataTables.bootstrap.css">
<script src="/public/js/datatables/js/jquery.dataTables.min.js"></script>
<!-- Imported scripts on this page -->
<script src="/public/js/datatables/dataTables.bootstrap.js"></script>
<script src="/public/js/datatables/yadcf/jquery.dataTables.yadcf.js"></script>
<script src="/public/js/datatables/tabletools/dataTables.tableTools.min.js"></script>
<link rel="stylesheet" href="/public/layui/css/layui.css"  media="all">
*{<script src="/public/layui/layui.js" charset="utf-8"></script>}*
<script src="/public/layui/layui.all.js" charset="utf-8"></script>

<script type="text/javascript">
    ;!function(){
        //无需再执行layui.use()方法加载模块，直接使用即可
        var laypage = layui.laypage
            ,layer = layui.layer;
        laypage.render({
            elem: 'layerPage',
            pages: '${resultPage?.pageCount}', //总页数
            count:'${resultPage?.size()}',
            limit:20,
            skip: true, //是否开启跳页
            skin: 'yahei',
            curr:$('#pageNumber').val()
            ,layout: ['count', 'prev', 'page', 'next',  'skip','skin'],
            jump: function(e, first){ //触发分页后的回调
                if(!first){ //一定要加此判断，否则初始时会无限刷新
                    $('#pageNumber').val(e.curr);
                    $("#searchForm").attr("action", "/BS0007/admin/merchant/index/"+e.curr);
                    $('#searchForm').submit();
                }
            }
        });

    }();

    $(document).ready(function(){
        // 提示
        var msg = '${flash.get("msg")}';
        if(msg) {
         //   saveSuccess(msg);
        }
        $(document).on("click", "#searchBtn", function(){
            $("#searchForm").attr("action", "/BS0007/admin/merchant/index/1");
            $('#searchForm').submit();
        })
    });


    //点击确认删除 之后执行的方法
    function sureDeleted() {
        //获取删除的id
        var id = $('#deleteId').val();
        document.location.href='/BS0007/admin/merchant/delete/'+id+'/${pageNumber}';
    }

    //导出
    function exportExcel() {
        var url = '/BS0007/admin/merchant/exportExcel';
        $("#searchForm").attr("action", url);
        $('#searchForm').submit();
    }

</script>


